The present invention relates generally to object oriented computer programming and more particularly to object oriented computer programming implemented in the Java programming language.
Java is an object-oriented programming language developed by Sun Microsystems, Mountain View, Calif. Java is a portable and architecturally neutral language. Java source code is compiled into a machine-independent format that can be run on any machine with a Java runtime system known as the Java Virtual Machine (JVM). The JVM is defined as an imaginary machine that is implemented by emulating a processor through the use of software on a real machine. Accordingly machines running under diverse operating systems, including UNIX, Windows NT, and MacIntosh having a JVM can execute the same Java program.
Web browsers including Netscape Navigator(copyright) and Microsoft Internet Explorer(copyright) are referred to as Java-enabled browsers because they include a version of the JVM. Java applets are programs written in Java and configured to run within Java-enabled browsers. Handled in a manner similar to the way images are handled, Java applets are displayed as part of a HyperText Mark Up Language (HTML) document. When an applet is loaded, it can present special effects, such as animation, graphics, and sound, perform real-time data updates and applications, and can interact with a user through a mouse, keyboard and various interface elements such as buttons, slides and text fields.
Java source code is compiled into bytecode using a Java compiler referred to as a Javac. Compiled Java programs are saved in files with the extension xe2x80x9cclassxe2x80x9d. When a Java-enabled web browser recognizes that an applet has been requested, a Java interpreter program runs the applet bytecode on the JVM.
Up until fairly recently, Java version 1.0 was the only version available. Java version 1.1 is now available and programs are being written utilizing various classes that are unique to version 1.1. JVMs enabled for Java version 1.0 cannot run classes written in Java version 1.1. As a result, when Java applets are encountered that contain method calls to version 1.1 classes, the applet crashes. Heretofore, the only available remedy for this problem has been to produce separate 1.0 and 1.1 versions of each Java applet. Unfortunately, the code maintenance that would be required for multiple versions of the same program renders this a rather impractical solution. Compounding the problem is that newer versions of Java are presently being developed. Unless users update their browsers to versions capable of running the latter versions of Java, the ability to run Java applets written in these newer versions will be thwarted.
In view of the above discussion, it is an object of the present invention to run Java applets containing features not supported by the JVM on which the applet has been called to run.
It is another object of the present invention to run Java applets written in any version of Java within any JVM without requiring separate Java versions of the applet.
These and other objects of the present invention are provided by methods, systems and computer program products for executing an application within a first version of a runtime system, wherein the application includes at least one call to an object class of a second version of the runtime system. According to one aspect of the present invention, an application, including each object class called by the application, is loaded into a first version of the runtime system. A class interface having at least one identifier for at least one respective object class of a second runtime system version called by the application is loaded into the first version of the runtime system. The application is then executed within the first version of the runtime system without causing an error condition by any of the calls to the second runtime system version object classes named in the class interface. Calls to object classes of the second runtime system version not identified within the downloaded class interface are not allowed. Operations may also include identifying each loaded second runtime system version object class and verifying that each identified second runtime system version object class has a respective identifier in the class interface.
According to a further aspect of the present invention, methods, systems and computer program products for executing an applet within a first Java version of a JVM running on a client, wherein the applet includes at least one call to a second Java version object class, are provided. A request to activate an applet is made to a server hosting the applet from a client. The Java applet, containing calls to various object classes, is then downloaded to the client. A class interface having a respective identifier for each respective second Java version object class called by the applet is also downloaded to the client. The downloaded applet is then executed within the JVM without causing an error condition by calls to a second Java version object class.
Each downloaded second Java version object class is identified by the loader within the JVM. The existence in the class interface of a respective identifier for each downloaded second Java version object class is verified. The downloaded applet is then executed within the JVM without causing error conditions by any calls to second Java version object classes having a respective identifier in the class interface. Calls to second Java version object classes not identified within the downloaded class interface are not allowed.
The present invention is advantageous because separate versions of a Java applet do not have to be written for each Java version of a JVM. When an applet is written in Java version 1.1, it may call methods that utilize classes available only to Java version 1.1. The class interface of the present invention contains a list of these Java version 1.1 classes. Both classes must be compiled with the interface, but only the version 1.1 class needs to implement the class interface. This allows the 1.0 compiler to compile the 1.0 class without needing to know the internals of the version 1.1 class, only the methods the 1.1 class implements as defined in the interface.